package com.nchu.student_score.controller;

import com.github.pagehelper.PageInfo;
import com.nchu.student_score.model.Course;
import com.nchu.student_score.service.CourseService;
import com.nchu.student_score.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/course")
public class CourseController {
    @Resource
    CourseService courseService;

    @RequestMapping("getCourseList/{currPage}")
    public PageInfo<Course> getCourseList(@RequestBody Course course, @PathVariable Integer currPage){
        return courseService.getCourseList(course,currPage);
    }

    @RequestMapping("updateCourse/{oldCourseId}")
    public ResultVo<Course> updateCourse(@RequestBody Course course, @PathVariable Integer oldCourseId){
        return courseService.updateCourse(course,oldCourseId);
    }

    @RequestMapping("getCourses")
    public ResultVo<Course> getAllCourse(){
        return courseService.getAllCourse();
    }
}
